package string;

/**
 * 344. 反转字符串
 * 双指针法
 *
 * @author Api
 * @date 2023/10/14 15:02
 */
public class Code344_InvertedString {
    public void reverseString(char[] s) {
        int len = s.length;
        for (int i = 0, j = len - 1; i < len / 2; i++, j--) {
            swap(s, i, j);
        }
    }

    private static void swap(char[] s, int i, int j){
        char temp = s[i];
        s[i] = s[j];
        s[j] = temp;
    }
}
